/**
 * Created by zhoushg on 2017/9/29.
 */
import getData from './funcs/getData'
import {isEmptyObject, isEmptyStr, isRange} from './funcs/required'
import {toast} from '../utils/gui_main'
import { getToken } from '../utils/auth'
 // addCode
			// H144fWVXV Start
		
        export function GTuser (params) { // user-登录
            var data = params
            return new Promise(resolve => {
            
        if (isEmptyStr(data.userName)) {
          toast.warn('用户名称不能为空')
          resolve(false)
          return
        }
          if(!isRange(data.userName,5,30)){
            toast.warn('用户名称输入不正确')
            resolve(false)
            return
          }
						
        if (isEmptyStr(data.password)) {
          toast.warn('密码不能为空')
          resolve(false)
          return
        }
        if (isEmptyStr(data.code)) {
          toast.warn('校验码不能为空')
          resolve(false)
          return
        }
            let data2 = {
              
            userName: data.userName, // 用户名称
            password: data.password, // 密码
            code: data.code // 校验码
            }
            params = data2
              function callBack (data) {
                resolve(data)
              }
              getData({
                url: '/user/list',
                method: 'get',
                params
              }, callBack)
            })
          }
        
		// H144fWVXV end
			
			// ryvVMZVX4 Start
		
        export function ADuser (data) { // user-注册
            var data = data
            return new Promise(resolve => {
            
        if (isEmptyStr(data.userName)) {
          toast.warn('用户名不能为空')
          resolve(false)
          return
        }
          if(!isRange(data.userName,5,30)){
            toast.warn('用户名输入不正确')
            resolve(false)
            return
          }
						
        if (isEmptyStr(data.password)) {
          toast.warn('密码不能为空')
          resolve(false)
          return
        }
        if (isEmptyStr(data.code)) {
          toast.warn('验证码等等不能为空')
          resolve(false)
          return
        }
            let data2 = {
              
            userName: data.userName, // 用户名
            phone: data.phone, // 电话
            password: data.password, // 密码
            code: data.code, // 验证码等等
            date: data.date, // 最后一次上线时间
            email: data.email // 邮箱
            }
            data = data2
              function callBack (data) {
                resolve(data)
              }
              getData({
                url: '/user/add',
                method: 'post',
                data
              }, callBack)
            })
          }
        
		// ryvVMZVX4 end
			
			
			
			
			

